package cn.edu.zxj.springblog.config;

import cn.edu.zxj.springblog.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-02-04
 * @time: 18:05:44
 */
@ControllerAdvice
@Slf4j
@ResponseBody
public class ErrorAdvice {
    @ExceptionHandler
    public Result exceptionAdvice(Exception e) {
        log.error("发生错误, e: {}", e);

        return Result.fail("内部发生错误, 请联系管理员");
    }
}
